package com.Trainer.TestInterface;

import com.Trainer.TrainerInterface.TrainerBottomLeftPanel;
import com.data.TrainerData;
import javax.swing.*;
import java.awt.*;

public class TestBottomLeftPanel extends TrainerBottomLeftPanel {
    //属性
    JLabel timeLabel;
    JLabel time ;
    JButton start;
    JButton submit;


    public TestBottomLeftPanel(int x, int y, int weight, int height, TrainerData data) {
        super(x, y, weight, height, data);
        super.getConfirmBtn().setText("上一题");

        start = new JButton("开始测试");
        submit = new JButton("提交测试");
        time = new JLabel("300");
        timeLabel = new JLabel("倒计时:");

        submit.setVisible(false);
        super.getNextBtn().setVisible(false);
        super.getConfirmBtn().setVisible(false);
        submit.setEnabled(false);
        super.getNextBtn().setEnabled(false);
        super.getConfirmBtn().setEnabled(false);
        super.getAnsJudge().setVisible(false);

        //标签修饰
        setLabel(timeLabel,450,0,80,50,20);
        setLabel(time,530,0,50,50,20);

        //按钮修饰
        start.setBounds(240,280,180,60);
        start.setFont(new Font("微软雅黑",Font.PLAIN,30));
        submit.setBounds(360,280,180,60);
        submit.setFont(new Font("微软雅黑",Font.PLAIN,30));

        //组件加入
        add(time);
        add(timeLabel);
        add(start);
        add(submit);
    }

    public JLabel getTime() {
        return time;
    }

    public JButton getStart() {
        return start;
    }

    public JButton getSubmit() {
        return submit;
    }

    public boolean setTime() {
        this.time.setText(""+(Integer.parseInt(this.time.getText())-1));
        return !this.time.getText().equals("0");
    }
}
